import requests
import re
import os

url = "https://svipsvip.ffzy-online5.com/20250329/39719_a528bca9/2000k/hls/mixed.m3u8"
res = requests.get(url)
tss = re.findall(r'\n(.*?\.ts)', res.text)

video_folder = './视频/斗破苍穹年番'
if not os.path.exists(video_folder):
    os.makedirs(video_folder)

video_file_path = os.path.join(video_folder, '斗破苍穹年番.mp4')

for ts in tss:
    movie_url = f"https://svipsvip.ffzy-online5.com/20250329/39719_a528bca9/2000k/hls/{ts}"
    ts_response = requests.get(movie_url)
    if ts_response.status_code == 200:
        with open(video_file_path, 'ab') as f:
            f.write(ts_response.content)
        print(f"成功下载并追加 {ts}")
    else:
        print(f"下载 {ts} 失败，状态码: {ts_response.status_code}")

print("所有TS文件下载完成，视频已保存到", video_file_path)
